<%--
 *  File:   HospitalInfoSaleStockWarnReport.jsp
 *  Desc:	Report Director depend on eSpreadsheet
 *
 *  Date		         Author		      Changes
 *  2013-01-23	  		 shigang	 	  Created
 *    
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%//init param
			String privilegeCode = "1201";
			//String strTableName = "";
			String strModuleName = "COM";
			String contextPath = request.getContextPath();

			%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<%@ include file="/rpt/ReportURL.inc"%>
<%@ page import="java.util.*"%>
<iframe name="reloadHandler" style="display:none"></iframe>
<html>
<head>
<title>HospitalInfoSaleStockWarnReport.jsp</title>
<PageFlow:CheckPageFlow pageName="p_dayormonthdatatransferreport" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>
<%Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
			if (totalsummary == null)
				totalsummary = new Vector();		

			HashMap deptinfo = (HashMap) session.getAttribute("deptinfo");
			if (deptinfo == null)
				deptinfo = new HashMap();
			
			HashMap UserInfo = (HashMap) session.getAttribute("userinfo");
			if (UserInfo == null)
				UserInfo = new HashMap();
    Integer loginemployeeid = (Integer)UserInfo.get("employeeid");
    
    java.util.Calendar cal = java.util.Calendar.getInstance(); 
    String flag = (String)pageContext.getAttribute("flag");
    
    HashMap orgInfo = (HashMap)pageContext.getAttribute("orginfo");

    if(orgInfo == null)
      orgInfo = new HashMap();
    
    Integer ishead = (Integer)orgInfo.get("ischain");
    if(ishead==null)
  	  ishead = new Integer(-1);
			%>

<%--  put your custom script here   --%>
 
<script language="JavaScript">
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  	editform.action = "DoctorPrescribedFormReport.jsp?<%= OvalTools.randomURL() %>";
    editform.target = "_self";
    isRunning = true;
    editform.submit();
}

function page_popBusinessarea()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/ogm/zylstdbusinessareapop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function page_popProductbrand()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/upm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function popCountyArea()
{
  if (typeof popwindow != 'undefined') popwindow.close();
  popwindow = window.open("<%=contextPath%>/masterdata/map/CountyAreaAllWindow.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>","newwindow", "height=300, width=800,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
	
}

function setCountyArea(userid,countyareaname,countyareaid,countyareacode)
{
	document.cform.countyareaname.value=countyareaname;
	document.cform.countyareacode.value=countyareacode;
}
function popRep() {
	

	var zylareacode=document.cform.businessareacodes.value;
	//var proviceofficecode = document.cform.proviceofficelist.value;
	//var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "<%=contextPath%>/tdr/dataverify/SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&zylareacode="+zylareacode;
  
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.employeeid.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

function setContact(id,type,name){

	document.cform.regionareaid.value=id;
	document.cform.regionname.value=name;
}

function set_orgNameByPopWindow(productgroupid,productgroupcode,productgroupname){

	document.cform.productbrandid.value=productgroupid;
	document.cform.productbrandname.value=productgroupname;
}
var popwindow;

function popBusinessarea_moulty(){
	if(popwindow!=null) popwindow.close();
	
    url = '<%=contextPath %>/phap/phap.datp/masterdata/cm/dataclean/ZylStdareaSelect.jsp?<%= OvalTools.randomURL() %>';
    attribute = 'height=500, width=900,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
	popwindow = window.open(url,'newwindow', attribute);
}

function setAreas(areaids,areanames,areacodes){

	document.cform.areaids.value = areaids;
	document.cform.businessareanames.value = areanames;
	document.cform.businessareacodes.value = areacodes;
} 

function page_selectDept(){
	if(popwindow!=null)
	    popwindow.close();
	  popwindow = window.open('<%=contextPath %>/phap/masterdata/erm/StandardDeptSummaryForPop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}

function setDept(value,name){
	document.cform.standardsectionid.value=value;
	document.cform.deptname.value=name;
	
}
function setRealityDept(code,name){
	document.cform.realitydeptcode.value=code;
	document.cform.realitydeptname.value=name;
	
}
function page_HospitalSummaryForPop(){
	if(popwindow!=null)
	    popwindow.close();
	  popwindow = window.open('<%=contextPath %>/phap/masterdata/erm/zylRealityDeptSummaryForPop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}
function exportAreaPeople(){
	//cform.deptid.options[0].selected=true;
	/**
	deptid 		   	部门Id
	regionareaid 	省区Id
	employeeid      员工id
	startdate     	期间开始时间
	enddate     	期间开始时间
	flowtype        流向类型
	durationtype    时间类型
	whethereai      是否直连
	*/
	//if(!checkSalesQty()) return;
	if(!checkForm(document.cform))return; 
	var deptid = document.cform.deptids.value;
	var areaids = document.cform.areaids.value;
	var employeeid=document.cform.employeeid.value;
	var startyears=document.cform.startyears.value;
	var startmonths=document.cform.startmonths.value;
	var endyears=document.cform.endyears.value;
	var endmonths=document.cform.endmonths.value;
	var prodid=document.cform.prodid.value;
	var categoryid=document.cform.categoryid.value;
	//var svolatility = document.cform.svolatility.value;
    //var tvolatility = document.cform.tvolatility.value;
    //var evolatility = document.cform.evolatility.value;
	if(categoryid == 4){
	  categoryid=1;
	}else{
	 if(categoryid ==5){
	  categoryid=2;
	 }
	}
	<%
	Vector periodmanagervector = (Vector) pageContext.getAttribute("periodmanagervector");
	if (periodmanagervector == null)
		periodmanagervector = new Vector();
	for(int i=0;i<periodmanagervector.size();i++){
	%>
	   if(startyears==<%=((HashMap)periodmanagervector.get(i)).get("year")%> && startmonths==<%=((HashMap)periodmanagervector.get(i)).get("month")%>){
	       document.cform.startdate.value="<%=((HashMap)periodmanagervector.get(i)).get("startdate")%>";
	   }
	   if(endyears==<%=((HashMap)periodmanagervector.get(i)).get("year")%> && endmonths==<%=((HashMap)periodmanagervector.get(i)).get("month")%>){
	       document.cform.enddate.value="<%=((HashMap)periodmanagervector.get(i)).get("enddate")%>";
	   }
	<%}%>
	
	var url = "<%=reportURL%>/servlet/ExcecuteReport/HospitalInfoSaleStockWarnReport.sox?__format=xlsx&__folder=/ovalreport";
	url=url+"&deptid="+deptid+"&areaids="+areaids+"&employeeids="+employeeid+"&begindate="+document.cform.startdate.value+"&enddate="+document.cform.enddate.value+"&prodid="+document.cform.prodid.value+"&categoryid="+categoryid;
    //var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	//popwindow = window.open(url, "n1window", strstatus);
	DataReport(url);
}
function page_selectProd() {
        var categoryid=document.cform.categoryid.value;
		var status = "height=400, width=600,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no";
		var url = "<%=contextPath%>/phap/phap.datp/masterdata/kdm/ProductSelect.jsp?o_thread=" + Math.random();
		if(categoryid == 4){
		  categoryid=1;
		  var url = "<%=contextPath%>/phap/phap.datp/masterdata/kdm/ProductSelect.jsp?o_thread=" + Math.random()+"&categoryid="+categoryid;
		}
		if(categoryid ==5){
		  categoryid=2;
		  var url = "<%=contextPath%>/phap/phap.datp/masterdata/kdm/ProductSelect.jsp?o_thread=" + Math.random()+"&categoryid="+categoryid;
		}
		if (typeof popwindow != 'undefined') popwindow.close();
		popwindow = window.open(url, "newwindow", status);
	}
function page_setproduct(id,umcode,prodcode,prodname){
		document.cform.prodid.value=id;
		document.cform.prodname.value=prodname;
		document.cform.prodcode.value=prodcode;
}
function checkSalesQty(){
   var svolatility = document.cform.svolatility.value;
   var tvolatility = document.cform.tvolatility.value;
   var evolatility = document.cform.evolatility.value;
   var qtyReg = /^[<|>][=|\d](-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/;
   var isDigit = /^(-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/;
   if(!isEmpty(svolatility)){
	 if(!qtyReg.test(svolatility)){
		alert('<%= message.getMessageDesc("A_Must_Like_B","纯销量波动率",">/>=/</<=/数字") %>');
		return false;	
	 }
   }
   if(!isEmpty(tvolatility)){
	 if(!qtyReg.test(tvolatility)){
		alert('<%= message.getMessageDesc("A_Must_Like_B","购进量波动率",">/>=/</<=/数字") %>');
		return false;	
	 }
   }
  if(!isEmpty(evolatility)){
	if(!qtyReg.test(evolatility)){
	    alert('<%= message.getMessageDesc("A_Must_Like_B","期末库存波动率",">/>=/</<=/数字") %>');
		return false;	
	}
   }
   return true;
}
</script>

</head>
<body style="overflow: auto;" >
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
	<input type="hidden" name="pagename" value="p_dayormonthdatatransferreport">
	<input type="hidden" name="actionname">
	<input type="hidden" name="prodcode">
    <input type="hidden" name="flag"/>
    <custom:hidden property="startdate"/>
    <custom:hidden property="enddate"/>
	<custom:hidden property="languagecode" scope="session" name="userinfo"/>
	<custom:hidden property="contactid" scope="session" name="userinfo" changedName="loginid"/>
	<%--  page location   --%>
<%@ include file="/inc/PageLocation.inc"%>


<table width="80%" border="0" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
<!-------------------------------------1 row -------------------------------------------------->
	<tr>
			<%
                SimpleDateFormat formatter1 = new SimpleDateFormat ("yyyy-MM-dd");
                String str_date_end=formatter1.format(new Date());
            %>
		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Department")+ label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td>
			<custom:select property="deptids" optionsName="alldeptnames" optionValueKey="deptid" optionInnerTextKey="deptname" defaultValue="--------" defaultValueCost=""/>
	    </td>
	     <td class="title_center">
	      <%
                  String year = cal.get(Calendar.YEAR)+"";     
				  String month = cal.get(Calendar.MONTH)+"";
				  if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
				  }  
		  %>
		 <div align="right">
		    <%= label.getLabelName("L_Year") + label.getLabelName("L_Colon") %>
		 </div>
		 </td>
		  
	   <td>
	        <!--  
	        <custom:text property="startdate"  dataType="date"  module="IMG" size="15" name="onehash"/><a onclick="javascript:c.show(this,'cform.startdate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
			~
			<custom:text property="enddate" dataType="date" dataFormatName="dateformat"  size="15" value="<%=str_date_end %>"/><a onclick="javascript:c.show(this,'cform.enddate','yyyy-MM-dd');"><custom:button type="3" label="L_Asterisk" imgsrc="Time.gif" border="0"/></a>
            -->
         
         <custom:selectdic property="startyears" dictType="Years" label="L_Year1"  value="<%=year %>"/>
		 <custom:selectdic property="startmonths" dictType="Months" label="L_Month" value="<%=month %>"/>
		 -
		 <custom:selectdic property="endyears" dictType="Years" label="L_Year1"  value="<%=year %>"/>
		 <custom:selectdic property="endmonths" dictType="Months" label="L_Month" value="<%=month %>"/>
       </td>
		<td class="title_center">
			<div align="right">
				<%=label.getLabelName("L_Provicetdr")+label.getLabelName("L_Colon")%>
			</div>
		</td>
		<td>
			<custom:text property="businessareanames"  size="20" readonly="false" style="border:1px #7F9DB9 solid;" />
		    <a onClick="javascript:popBusinessarea_moulty();">
		    <custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" />
		    </a><custom:hidden property="areaids" /><custom:hidden property="businessareacodes" />
		</td>			
		<td>
		 <div align="right">
		  <%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %>
		 </div>
		</td>
	    <td>
			<custom:text property="employeename" size="20"  style="border:1px #7F9DB9 solid;"/>
		    <a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			<custom:hidden property="employeeid"/>
			<custom:hidden property="employeecode"/>
	    </td>
	</tr>
<!-------------------------------------2 row -------------------------------------------------->
	<tr>
	   <td class="title_center">
			<div align="right">
				 <%=label.getLabelName("L_ProdCategory") +  label.getLabelName("L_Colon") %>
			</div>
		</td>
	   <td>
			<custom:selectdic dictType="PatentOrPopular" property="categoryid"  defaultValue="------" defaultValueCost=""  label="L_ProdCategory" valueCriteria="4,5"/>
       </td>
       <td class="title_center">
			<div align="right">
				 <%=label.getLabelName("L_Product") +  label.getLabelName("L_Colon") %>
			</div>
		</td>
	   <td>
			<custom:text property="prodname" readonly="false"  /> 
			<a onclick="javascript:page_selectProd();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
			<custom:hidden property="prodid" /> 
			<custom:hidden property="prodcode" />
       </td>
       <!-- 
       <td class="title_center">
			<div align="right">
				 <%="纯销量波动率" +  label.getLabelName("L_Colon") %>
			</div>
		</td>
	   <td>
			<custom:text property="svolatility"   /> 
       </td>
        <td class="title_center">
			<div align="right">
				 <%="购进量波动率" +  label.getLabelName("L_Colon") %>
			</div>
		</td>
	   <td>
			<custom:text property="tvolatility"   /> 
       </td>
        -->
	</tr>
<!-------------------------------------3 row -------------------------------------------------->
<!-- 
<tr>
        <td class="title_center">
			<div align="right">
				 <%="期末库存波动率" +  label.getLabelName("L_Colon") %>
			</div>
		</td>
	   <td>
			<custom:text property="evolatility"   /> 
       </td>
</tr>
 -->
<!--	-----------------------------------------4row---------------------------------------->

 </table>

		 <table width="100%" cellspacing="0" cellpadding="0">
		        <tr>
		          <td class="summary_top"></td>
		        </tr>
		        
		        <tr>
		          	<td class="td_center">
			  		
				  		
				  		<a onclick="javascript:exportAreaPeople();"><custom:button type="1" label="L_Execcd" imgsrc="CreatSubDept.gif" border="0"/></a>

					</td>
		        </tr>
     	</table>
</form>
</body>
</html>
